package com.foreveross.action;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.foreveross.common.CommonUtil;
import com.foreveross.service.ExpressService;
import com.foreveross.service.HouseRepairService;
import com.foreveross.service.LogService;
import com.foreveross.service.ReservationService;
import com.foreveross.vo.Express;
import com.foreveross.vo.Untreated;
import com.foreveross.vo.common.PageVo;
import com.foreveross.vo.common.ResultVo;

@Controller
@RequestMapping(value = "/sysUntreatedController")
public class SysUntreatedController {

	private Logger log = Logger.getLogger(SysUntreatedController.class);
			
	@Resource
	private ExpressService expressService;
	
	@Resource
	private ReservationService reservationService;
	
	@Resource
	private HouseRepairService houseRepairService;
	
	@Resource
	private LogService logService;
	
	@RequestMapping(method = RequestMethod.POST, value = "/getUntreated")
	public void getUntreated(HttpServletRequest request,
			HttpServletResponse response, String page,String rows,String userId) {
		ResultVo resultVo = new ResultVo();
		try {
			//前台自己未处理数
			int countExpress = (int) expressService.getExpressListCount(
					null,null, null, "1", "1", null,null,userId,null);
			//代收未处理数
			int countRecord = (int) expressService.getExpressListCount(
					null,null, null, "2", "4", null,null,userId,null);
			//预约未处理数
			int countReservation = (int)reservationService.findReservationListCount(
					null, null, null, null, null, null, "0", userId,null);
			//保修未处理数
			int countHouseRepair = (int) houseRepairService.getHouseRepairListCount(
					null, null, null, null, null, "0",  null,null,userId);
			
			Untreated untreated = new Untreated(countExpress, countRecord, countReservation, countHouseRepair);
			resultVo.setData(untreated);
			resultVo.setSuccess(true);
		} catch (Exception e) {
			resultVo.setSuccess(false);
			resultVo.setMessage("快递信息  查看失败");
			log.error("快递信息 查看失败!", e);
		}
		CommonUtil.PrintWriterResultVoWithJSON(response, resultVo);
	}
}
